# creational pattern（创建型）
# -> abstract factory pattern（抽象工厂模式）
from abc import ABC, abstractmethod
##########################################
# 产品Button
class Button(ABC):
    @abstractmethod
    def on_click(self):
        pass

class WindowsButton(Button):
    def on_click(self):
        print('I\'m a WindowsButton')

class MacButton(Button):
    def on_click(self):
        print('I\'m a MacButton')

class LinuxButton(Button):
    def on_click(self):
        print('I\'m a LinuxButton')

# 产品Label
class Label(ABC):
    @abstractmethod
    def play(self):
        pass

class WindowsLabel(Label):
    def play(self):
        print("I'm a WindowsLabel")

class MacLabel(Label):
    def play(self):
        print("I'm a MacLabel")

class LinuxLabel(Label):
    def play(self):
        print("I'm a LinuxLabel")

##########################################
# 工厂
class Creator(ABC):
    @abstractmethod
    def createButton(self):
        pass

    @abstractmethod
    def createLabel(self):
        pass

class WindowsCreator(Creator):
    def createButton(self):
        return WindowsButton()

    def createLabel(self):
        return WindowsLabel()

class MacCreator(Creator):
    def createButton(self):
        return MacButton()

    def createLabel(self):
        return MacLabel()

class LinuxCreator(Creator):
    def createButton(self):
        return LinuxButton()

    def createLabel(self):
        return LinuxLabel()

##########################################
def main():
    creator = WindowsCreator()
    button = creator.createButton()
    label = creator.createLabel()

    button.on_click()
    label.play()

if __name__ == '__main__':
    main()